package com.example.SpringBootMybatis.common;

public class Result {
    private static final String SUCCESS ="0";
    private static final String ERROR = "-1";

    private String code; //状态码：成功或是失败
    private String msg; //后台报错信息
    private Object data; //返回的数据

    public static Result success(){
        Result result= new Result();
        result.code=SUCCESS;
        return result;
    }
    public static Result success(Object data){
        Result result = new Result();
        result.code=SUCCESS;
        result.data=data;
        return result;
    }
    public static Result error(String msg){
        Result result =new Result();
        result.code=ERROR;
        result.msg=msg;
        return result;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
